package com.jia.train.batch.job;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

@DisallowConcurrentExecution // 禁用并发执行
public class DistributedQuartzJob implements Job {

    public static final Logger logger = LoggerFactory.getLogger(DistributedQuartzJob.class);

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        // 如果这个任务没有执行结束 下个线程不能进来执行
        logger.info("执行任务的方法 开始: {}", jobExecutionContext);
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        logger.info("执行任务的方法 结束: {}", jobExecutionContext);

    }


}
